package com.ms.game.gameActivity;

import java.util.ArrayList;

import org.hibernate.Query;
import org.hibernate.Session;

import com.ms.game.gameActivity.db.GameActivitySettingModel;
import com.xpec.c4.db.hibernate.manager.HibernateManager;

public class GameActivityDAO {
	/**
	 * 載入活動設定
	 */
	public static ArrayList<GameActivitySettingModel> loadGameActivitySetting(String gameName) {
		
		String queryStr = gameName == null ? "from GameActivitySettingModel" : "from GameActivitySettingModel Where game = :GAME";
		
		Session session = HibernateManager.getSession();
		Query query = session.createQuery(queryStr);
		if(gameName != null){
			query.setParameter("GAME", gameName);	
		}
		@SuppressWarnings("unchecked")
		ArrayList<GameActivitySettingModel> list = (ArrayList<GameActivitySettingModel>) query.list();
		HibernateManager.endSession();
		return list;
	}
}
